<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCommentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('comments', function (Blueprint $table) {
            $table->increments('id')->unsigned()->comment("评论表");
            $table->integer('user_id')->unsigned()->comment("评论者id");
            $table->string('user_type')->comment("评论者的所属Model");
            $table->integer('object_id')->unsigned()->comment("被评论对象的id");
            $table->string('object_type')->comment("被评论对象的所属Model");
            $table->text('content')->nullable()->comment('评论内容');
            $table->integer('like_amount')->unsigned()->default(0)->comment('点赞量');
            $table->boolean('is_show')->default(true)->comment('是否展示');
            $table->timestamps();
        });

        Schema::create('comments_likes', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id')->comment('用户id');
            $table->integer('comments_id')->comment('评论id');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('comments');
        Schema::dropIfExists('comments_likes');
    }
}
